package org.dei.perla.rockfall.gui.queryforge;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;

class RunningStatus3Panel extends ReadableStatusPanel {

	private JComboBox jComboBox1;
	private JCheckBox jCheckBox2;

	public RunningStatus3Panel(String string) {
		super(string);
	}

	@Override
	protected int getStatus() {
		int retvalue = 0;
		
	

		int combo1 = this.jComboBox1.getSelectedIndex();
		boolean check2 = this.jCheckBox2.isSelected();
		
				
		switch(combo1){
			case 0:{
				retvalue |= 0x0000;
				break;
			}
			case 1:{
				retvalue |= 0x0001;
				break;
			}
			case 2:{
				retvalue |= 0x0002;
				break;
			}
			case 3:{
				retvalue |= 0x0003;
				break;
			}
			case 4:{
				retvalue |= 0x0004;
				break;
			}
			case 5:{
				retvalue |= 0x0005;
				break;
			}
			default:{
				break;
			}
		}
		
		if(check2)
			retvalue |= 0x10;

		return retvalue;
	}

	@Override
	protected void setStatus(int stato) {
		// TODO Auto-generated method stub
		this.jComboBox1.setSelectedIndex(stato&0xF);
		this.jCheckBox2.setSelected((stato&0x10)>0);
	}

	@Override
	protected void setupInternalComponents() {
		
		//Primo blocco di scelte
				
		jComboBox1 = new JComboBox();
		jComboBox1.setEditable(false);
		jComboBox1.addItem("disabilitato");
		jComboBox1.addItem("1:2");
		jComboBox1.addItem("1:4");
		jComboBox1.addItem("1:8");
		jComboBox1.addItem("1:16");
		jComboBox1.addItem("1:32");
		jComboBox1.setSelectedIndex(0);
		
		JLabel jlabel1 = new JLabel("Imposta fattore di downsampling");
		JPanel jpanel1 = new JPanel();
		BoxLayout layout1 = new BoxLayout(jpanel1, BoxLayout.X_AXIS);
		jpanel1.add(jlabel1);
		jpanel1.add(jComboBox1);
		
        //Secondo Blocco di scelte
		jCheckBox2 = new JCheckBox();
		jCheckBox2.setSelected(true);
		JLabel jlabel2 = new JLabel("Abilita filtro IIR passa alto");
		JPanel jpanel2 = new JPanel();
		BoxLayout layout2 = new BoxLayout(jpanel1, BoxLayout.X_AXIS);
		jpanel2.add(jlabel2);
		jpanel2.add(jCheckBox2);
		
		//aggiungo tutti i blocchi
		this.add(jpanel1);
		this.add(jpanel2);

	}

}
